<?php

/**
 * Created by PhpStorm.
 * User: Yieong
 * Date: 16/4/20
 * Time: 下午8:35
 */
class ModStep {

    public static function getData($params){
        $where = ' WHERE RecDate BETWEEN :begin AND :end
                    AND Period=:period
                    AND Platform=:platform
                    AND GameSrc=:game
                    AND SID=:server
                    AND Job=:job';
        $args = array(
            ':begin'    => $params['begin'],
            ':end'      => $params['end'],
            ':period'   => 'Daily',
            ':platform' => $params['p'],
            ':game'     => $params['g'],
            ':server'   => $params['server'],
            ':job'      => $params['job']
        );

        $sql = 'SELECT StepID, ParentID, SUM(Cnt) AS Cnt, MAX(CumCnt) AS CumCnt FROM tblGameSteps '.$where.' GROUP BY StepID, ParentID';
        $dbLink = new PubDbLink('dbSelf', PubDatabase::getMgmtDbName($params['p'],$params['g']));
        return $dbLink->query($sql, $args);
    }

}